home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / 2DLab / simple.c < prev    next >
Encoding:
Text File  |  1992-01-14  |  512 b   |  19 lines

  1. #import "TwoDView.h" /* the main class */
  2. #import "TwoDTSP.h"    /* this category */
  3.  
  4. #define FROM 0
  5. #define TO 1
  6. float simpleTSP(int n,float *data,float *distances,int *edges);
  7.  
  8. /* everything is allocated before it comes in */
  9. float simpleTSP(int n,float *data,float *distances,int *edges)
  10. {
  11.      int x,opt;
  12.      for(x=0;x<n-1;x++) {/* calculate the distances*/
  13.       opt += distances[x][x+1];
  14.       edges[x][FROM] = x; /* connect the first one to the second one ...*/
  15.       edges[x][TO] = x+1
  16.      }
  17.      return opt;
  18. }
  19.